<?php

namespace App\Http\Api\Controllers;

use App\Exceptions\InvalidRequestException;
use App\Http\Admin\Services\Config\ConfigService;
use App\Http\Controllers\Controller;
use App\Http\Models\FxgShopGoodsLogs;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;


class GoodsSuperviseController extends Controller
{
    protected $service;
    public function __construct(ConfigService $configService)
    {
        $this->service = $configService;
    }


    public function store(Request $request){

        $data   =   $request->input('data') ?? '';

        if(!empty($data)){

            $data   =   json_decode($data,true);

            foreach ($data as $k=>$v){
                $v['created_at'] =   date("Y-m-d H:i:s");
                $v['updated_at'] =   date("Y-m-d H:i:s");
                $v['product_name'] =   (string)$v['product_name'];
                $data[$k]   =   $v;
            }


            FxgShopGoodsLogs::insert($data);

        }

        return res('ok');

    }


    /*
    * 配置获取
    * */
    public function shops(Request $request)
    {
        $key = $request->input('key') ?? 'fxg_shops';


        $result = $this->service->getConf($key);

        return res('获取成功',$result);
    }
}